package whf.framework.meta.web;

import java.util.List;

import whf.framework.entity.AbstractEntity;
import whf.framework.meta.entity.Object;
import whf.framework.meta.entity.ObjectProperty;
import whf.framework.meta.service.ObjectService;
import whf.framework.meta.service.ObjectServiceImp;
import whf.framework.web.struts.WebData;
import whf.framework.web.struts.WebDispatchAction;
import whf.framework.web.struts.WebForward;

/**
 * @author wanghaifeng
 * @email king@126.com
 * @modify 2006-05-31
 */
public class ObjectPropertyAction extends WebDispatchAction {

	@Override
	public WebForward list(AbstractEntity webEntity, WebData data) throws Exception {
		ObjectService service = ObjectServiceImp.getObjectService();
		List<Object> objects = service.find("order by t.subModule");
		data.setAttribute("objects", objects);
		long objectId = data.getLongParameter("objectId", 0);
		if(objectId != 0){
			Object obj = service.findByPrimaryKey(objectId);
			List<ObjectProperty> properties = obj.getSortedProperties();
			data.setAttribute("list", properties);
			return data.forward("list");
		}
		return super.list(webEntity, data);
	}

} 